//
// Copyright (c) 2009-2011, chunquedong
//
// This file is part of ChunMap project
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
//
// History:
//   2011-05-03  Jed Young  Creation
//

using chunmapModel

**
** FeatureList
**
@Js
class FeatureList : FeatureSet
{
  Feature[] features := [,]

  new make(|This| f) : super(f) {}

  override This add(Feature f) { features.add(f); return this }
  override Feature? remove(Feature f) { features.remove(f) }

  override Void each(Condition condition, |Feature| filter)
  {
    features.each |f|
    {
      if (condition.envelope == null || condition.envelope.intersects(f.envelope))
      {
        filter(f)
      }
    }
  }

  override Feature? find(Condition condition, |Feature->Bool| filter)
  {
    features.find |Feature f->Bool|
    {
      if (condition.envelope == null || condition.envelope.intersects(f.envelope))
      {
        return filter(f)
      }
      return false
    }
  }
}